<?php namespace Common\Model;
use Hdphp\Model\Model;
use Common\Model\Goods_attr;
class Goods_list extends Model{
	//指定表名
	protected $table="goods_list";
	//自动验证
	protected $vaildate=array(
	);
	//执行添加
	public function store(){
		if(!$this->create()) return FALSE;
		$combine=Q('post.combine');
		$gid=Q('post.shop_goods_gid');
		foreach($combine as $v){
			if($v==0) {
				$this->error="选项不能为空";
				return FALSE;
			}
		}
		$combine=implode('|', $combine);
		$com=$this->where("combine='{$combine}' AND shop_goods_gid={$gid}")->find();
		if($com){
			$this->error="该货品已存在，如要修改库存，请点击编辑按钮";
			return FALSE;
		}
		$this->data['combine']=$combine;
		$this->add();
		return TRUE;
	}
	//编辑
	public function edit(){
		if(!$this->create()) return FALSE;
		$combine=Q('post.combine');
		$gid=Q('post.shop_goods_gid');
		foreach($combine as $v){
			if($v==0) return FALSE;
		}
		$combine=implode('|', $combine);
		$this->data['combine']=$combine;
		$this->save();
		return TRUE;
	}
	
}

 ?>